//
//  YQAssetsHeadView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQAssetsHeadView.h"

@implementation YQAssetsHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupHeadView];
        self.backgroundColor = MainBlueColor;
    }
    return self;
}

//添加测试

- (void)setupHeadView {
    [self addSubview:self.totalAssetsLab];
    [self.totalAssetsLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(36));
        make.top.mas_equalTo(FIT(36));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(72), 30));
    }];
    
    [self addSubview:self.contentLab];
    [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(36));
        make.top.equalTo(self.totalAssetsLab.mas_bottom).mas_equalTo(FIT(21));
    }];
    
    [self addSubview:self.leftImg];
    [self.leftImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentLab.mas_right).mas_equalTo(FIT(20));
        make.top.equalTo(self.totalAssetsLab.mas_bottom).mas_equalTo(FIT(15));
        make.size.mas_equalTo(CGSizeMake(FIT(18), FIT(18)));
    }];
    
    
}

#pragma mark - dy
-(UILabel *)totalAssetsLab {
    if (!_totalAssetsLab) {
        _totalAssetsLab = [YQViewFactory labelWithTextColor:WhiteColor textAlignment:NSTextAlignmentLeft fontSize:kCoinsFont userBold:YES];
        _totalAssetsLab.text = @"2345.7896 WDC";
    }
    return _totalAssetsLab;
}

- (UIButton *)leftImg {
    if (!_leftImg) {
        _leftImg = [YQViewFactory buttonWithImage:YQ_IMAGE(@"copy") target:self sel:@selector(copyWithAddress)];
    }
    return _leftImg;
}

- (UILabel *)contentLab {
    if (!_contentLab) {
        _contentLab = [YQViewFactory labelWithTextColor:WhiteColor textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _contentLab.text = @"******";
    }
    return _contentLab;
}
//复制地址
- (void)copyWithAddress {
    UIPasteboard *paste = [UIPasteboard generalPasteboard];
    [paste setString:self.totalAssetsLab.text];
    if (paste == nil) {
        [LCProgressHUD showFailure:@"复制失败"];
    }else {
        [LCProgressHUD showSuccess:@"已复制到粘贴板"];
    }
}

@end
